@extends('layout')
@section('head')
    @parent
@stop
@section('content')
    @foreach($user as $user)
        <div class="profile_wrap">
            <div class="user_profile">{{$user['nickname']}}的个人主页
             @if($name==Session::get('nickname'))
            <button type="button" class="pro_btn" onclick="edit()">编辑</button>
            @endif
            </div>
             <div class="profile_item">
                <div class="profile_left">昵称</div>
                <div class="profile_right"><span>{{$user['nickname']}}</span></div>
            </div>
            <div class="profile_item">
                <div class="profile_left">邮箱</div>
                <div class="profile_right"><span>{{$user['email']}}</span></div>
            </div>
            <div class="profile_item">
                <div class="profile_left">性别</div>
                <div class="profile_right"><span id="sex">{{$user['sex']}}</span></div>
            </div>
            <div class="profile_item">
                <div class="profile_left">城市</div>
                <div class="profile_right"><span id="city">{{$user['city']}}</span></div>
            </div>
            <div class="profile_item">
                <div class="profile_left">职业</div>
                <div class="profile_right"><span id="pro">{{$user['profession']}}</span></div>
            </div>
            <div class="profile_item">
                <div class="profile_left">个性签名</div>
                <div class="profile_right"><span id="sign">{{$user['sign']}}</span></div>
            </div>
            @endforeach
        </div>
        <div class="profile_wrap">
            <div class="profile_comment">
                <div class="user_profile">{{$user['nickname']}}发表的评论</div>
                <div class="review_list">
                @foreach($review as $item)
                <div class="review_item" style="overflow: hidden">
                    <div class="review_img">
                        <a href="{{url('detail')}}/{{$item['film_id']}}"><img src="{{$item['poster']}}"></a>
                    </div>
                    <div class="review_detail">
                        <a href="{{url('detail')}}/{{$item['film_id']}}" style="font-size: 14px" class="review_title">{{$item['title']}}</a>
                        <div class="review_info"><a href="{{url('profile')}}/{{$item['user_name']}}">{{$item['user_name']}}</a>
                            @if($item['rating']>9&&$item['rating']<=10)
                                <span class="rating_five"></span>
                            @elseif($item['rating']<=9&&$item['rating']>8)
                                <span class="rating_fours"></span>
                            @elseif($item['rating']<=8&&$item['rating']>7)
                                <span class="rating_four"></span>
                            @elseif($item['rating']<=7&&$item['rating']>6)
                                <span class="rating_threes"></span>
                            @elseif($item['rating']<=6&&$item['rating']>5)
                                <span class="rating_three"></span>
                            @elseif($item['rating']<=5&&$item['rating']>4)
                                <span class="rating_twos"></span>
                            @elseif($item['rating']<=4&&$item['rating']>3)
                                <span class="rating_two"></span>
                            @elseif($item['rating']<=3&&$item['rating']>2)
                                <span class="rating_ones"></span>
                            @elseif($item['rating']<=2&&$item['rating']>1)
                                <span class="rating_one"></span>
                            @elseif($item['rating']<=1&&$item['rating']>0)
                                <span class="rating_zeros"></span>
                            @else
                                <span class="rating_zero"></span>
                            @endif
                            <span class="comment_time">{{$item['time']}}</span>
                            <span><img style="position: relative;top: 3px;" src="{{URL::asset('assets/img/praise.png')}}">{{$item['assist_num']}}</span></div>
                        <div class="review_content">{{$item['content']}}</div>
                    </div>
                </div>
            @endforeach
                {{$review->links()}}
                </div>
            </div>
        </div>
        <div class="profile_wrap">
            <div class="profile_comment">
                <div class="user_profile">{{$user['nickname']}}赞过的评论</div>
                <div class="review_list">
                @foreach($comment as $item)
                    <div class="review_item" style="overflow: hidden">
                        <div class="review_img">
                            <a href="{{url('detail')}}/{{$item['film_id']}}"><img src="{{$item['poster']}}"></a>
                        </div>
                        <div class="review_detail">
                            <a href="{{url('detail')}}/{{$item['film_id']}}" style="font-size: 14px" class="review_title">{{$item['title']}}</a>
                            <div class="review_info"><a href="{{url('profile')}}/{{$item['user_name']}}">{{$item['user_name']}}</a>
                                @if($item['rating']>9&&$item['rating']<=10)
                                    <span class="rating_five"></span>
                                @elseif($item['rating']<=9&&$item['rating']>8)
                                    <span class="rating_fours"></span>
                                @elseif($item['rating']<=8&&$item['rating']>7)
                                    <span class="rating_four"></span>
                                @elseif($item['rating']<=7&&$item['rating']>6)
                                    <span class="rating_threes"></span>
                                @elseif($item['rating']<=6&&$item['rating']>5)
                                    <span class="rating_three"></span>
                                @elseif($item['rating']<=5&&$item['rating']>4)
                                    <span class="rating_twos"></span>
                                @elseif($item['rating']<=4&&$item['rating']>3)
                                    <span class="rating_two"></span>
                                @elseif($item['rating']<=3&&$item['rating']>2)
                                    <span class="rating_ones"></span>
                                @elseif($item['rating']<=2&&$item['rating']>1)
                                    <span class="rating_one"></span>
                                @elseif($item['rating']<=1&&$item['rating']>0)
                                    <span class="rating_zeros"></span>
                                @else
                                    <span class="rating_zero"></span>
                                @endif
                                <span class="comment_time">{{$item['time']}}</span>
                                <span><img style="position: relative;top: 3px;" src="{{URL::asset('assets/img/praise.png')}}">{{$item['assist_num']}}</span></div>
                            <div class="review_content">{{$item['content']}}</div>
                        </div>
                    </div>
                @endforeach
                {{$comment->links()}}
                </div>
            </div>
        </div>
    <div id="hidden" style="display: none">
        <div class="register_input">
            <div class="register_item">
                <label>性别</label>
                <span class="register_radio"><input type="radio" name="sex" value="保密">&nbsp;&nbsp;&nbsp;保密</span>
                <span class="register_radio"><input type="radio" name="sex" value="男">&nbsp;&nbsp;&nbsp;男</span>
                <span class="register_radio"><input type="radio" name="sex" value="女">&nbsp;&nbsp;&nbsp;女</span>
            </div>
            <div class="register_item">
                <label>城市</label><input class="register_item_input" name="city">
            </div>
            <div class="register_item">
                <label>职业</label><input class="register_item_input" name="pro">
            </div>
            <div class="register_item">
                <label>个性签名</label><textarea id="sign_textarea" name="sign"></textarea>
            </div>
        </div>
    </div>
<script>
    function edit() {
            var elem=$("#hidden");
            var d1 = dialog({
                title: '编辑个人信息',
                okValue: '保存',
                ok: function() {
                    $.post("{{url("saveProfile")}}",
                        {
                            name:"{{$name}}",
                            sex:$("input:radio:checked").val(),
                            pro: $("input[name='pro']").val(),
                            city:$("input[name='city']").val(),
                            sign:$("textarea[name='sign']").val()
                        },
                        function (data) {
                        if(data=='success'){
                            var d2=dialog({
                                okValue: '确定',
                                content: '编辑成功',
                                ok:function () {
                                    location.reload();
                                }
                            }).show();}
                            else{
                             alert(data);
                            }
                        }
                    );
                    return false;
                },
                cancelValue: '取消',
                cancel: function() {}
            });
            d1.content(elem).showModal();
    }
    $(function () {
       $(".pro_btn").hover(function () {
            $(this).attr("style","color:#008cc8");
       },
           function () {
           $(this).attr("style","color:#93999f");
       });

       //获取信息
        var sex=$("#sex").text();
        var city=$("#city").text();
        var pro=$("#pro").text();
        var sign=$("#sign").text();
        switch(sex) {
            case '男':
                $("input[value='男']").attr("checked", "checked");
                    break;
            case '女':
                $("input[value='女']").attr("checked", "checked");
                    break;
            case '保密':
                $("input[value='保密']").attr("checked", "checked");
        }
        $("input[name='city']").val(city);
        $("input[name='pro']").val(pro);
        $("textarea[name='sign']").val(sign);
    });
</script>
@stop
@section('foot')
    @parent
@stop

